export function getScollParent(el) {
  let _parent = el.parentNode;
  // console.log(_parent);
  //<div class="img-box"><img alt="..."></div>

  while (_parent) {
    const styleOverflow = getComputedStyle(_parent)['overflow'];

    //找到包含scroll或者auto时
    if (/(scroll)|(auto)/.test(styleOverflow)) {
      //证明是当前滚动的节点的父节点
      return _parent;
    }

    //找不到时往上层去找
    _parent = _parent.parentNode;
  }
}

export function imgLoad(src) {
  return new Promise((resolve, reject) => {
    const oImg = new Image();
    oImg.src = src;
    oImg.onload = resolve;
    oImg.onerror = reject;
  })
}